home *** CD-ROM | disk | FTP | other *** search
/ Nothing but Tetris / Nothing but Tetris.iso / amiga / yactris / src / about.c next >
C/C++ Source or Header  |  1994-01-01  |  4KB  |  204 lines

  1. /*
  2.     YacTris v0.0
  3.     Copyright ⌐1993 Jonathan P. Springer
  4.  
  5.     This program is free software; you can redistribute it and/or modify
  6.     it under the terms of the GNU General Public License as published by
  7.     the Free Software Foundation; either version 1, or (at your option)
  8.     any later version.
  9.  
  10.     This program is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.     GNU General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU General Public License
  16.     along with this program; if not, write to the Free Software
  17.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  
  19.     For more details see the files README and COPYING, which should have
  20.     been included in this distribution.
  21.  
  22.     The author can be reached during the school year at these E-Mail addresses:
  23.  
  24.     springjp@screech.alfred.edu        (Internet)
  25.     springjp@ceramics.bitnet        (Bitnet)
  26.  
  27.     And can be reached by paper mail year-round at the following address:
  28.  
  29.     Jonathan Springer
  30.     360 W. Main St.
  31.     Dallastown, PA    17313-2014
  32.     USA
  33.  
  34. */
  35.  
  36.  
  37. /*
  38. **
  39. **  about.c
  40. **
  41. **  This module contains routines for responding to the "About..." menu item
  42. **  and giving menu help.
  43. **
  44. */
  45.  
  46. /**************/
  47. /*  Includes  */
  48. /**************/
  49. #include <exec/types.h>
  50. #include <intuition/intuition.h>
  51. #include <libraries/gadtools.h>
  52. #include <utility/tagitem.h>
  53. #include <dbug.h>
  54. #include "yactris.h"
  55. #include <bruce.h>
  56.  
  57. /****************/
  58. /*  Prototypes    */
  59. /****************/
  60. #include <clib/exec_protos.h>
  61. #include <clib/intuition_protos.h>
  62. #include <clib/gadtools_protos.h>
  63. #include <clib/macros.h>
  64.  
  65. Prototype void DoAbout(struct ScreenInfo *);
  66.  
  67. /****************/
  68. /*  About Text    */
  69. /****************/
  70.  
  71. #define AB_LINES 12
  72.  
  73. const char *abTexts[AB_LINES] = {
  74.     "Yactris version 0.0",
  75.     "by Jonathan Springer",
  76.     NULL,
  77.     "Yactris comes with",
  78.     "ABSOLUTELY NO WARRANTY.",
  79.     NULL,
  80.     "Yactris is free software.",
  81.     "You are welcome to redistribute it",
  82.     "under certain conditions.",
  83.     NULL,
  84.     "See the files \"COPYING\" and \"README\"",
  85.     "for details."
  86. };
  87.  
  88. /*****************/
  89. /*  Actual Code  */
  90. /*****************/
  91.  
  92. /*
  93. **
  94. **  DoAbout()
  95. **
  96. **  Display the About window
  97. **
  98. */
  99. #define DA_GO_ON 13
  100.  
  101. void DoAbout(struct ScreenInfo *si)
  102. {
  103.     struct NewGadget ng = {
  104.     0, (AB_LINES+2)*si->font->ta_YSize + si->WTop,
  105.     0, 2*si->font->ta_YSize,
  106.     "Wow!", si->font,
  107.     DA_GO_ON, PLACETEXT_IN,
  108.     si->vi, NULL
  109.     };
  110.  
  111.     struct Window *w;
  112.  
  113.     struct IntuiText it = {
  114.     si->pens[SHADOW], si->pens[BACK], JAM1,
  115.     0,0, si->font, NULL, NULL
  116.     };
  117.  
  118.     int i, maxlen=0;
  119.  
  120.     struct Gadget *pgad=NULL, *glist;
  121.  
  122.     struct IntuiMessage *imsg;
  123.  
  124.     ULONG Class;
  125.     struct Gadget *g;
  126.     BOOL done = FALSE;
  127.  
  128.     DBUG_ENTER("DoAbout");
  129.  
  130.     for (i=0; i<AB_LINES; i++) if (abTexts[i]) {
  131.     it.IText = abTexts[i];
  132.     maxlen = MAX(maxlen, IntuiTextLength(&it));
  133.     }
  134.  
  135.     ng.ng_Width = maxlen/3;
  136.     ng.ng_LeftEdge = ng.ng_Width+si->WLeft+si->xTimes;
  137.  
  138.     pgad = CreateContext(&glist);
  139.  
  140.     if (pgad = CreateGadget(BUTTON_KIND, pgad, &ng, TAG_END) ) {
  141.  
  142.     if (w = OpenWindowTags(NULL, (Tag)
  143.         WA_IDCMP,        BUTTONIDCMP|
  144.                 IDCMP_CLOSEWINDOW|IDCMP_REFRESHWINDOW,
  145.         WA_Gadgets,     glist,
  146.         WA_Title,        "About YacTris",
  147.         WA_ScreenTitle,    "YacTris v0.0",
  148.         WA_InnerWidth,    maxlen+2*si->xTimes,
  149.         WA_InnerHeight,    (AB_LINES+5)*si->font->ta_YSize,
  150.         WA_PubScreen,    si->s,
  151.         WA_DragBar,     TRUE,
  152.         WA_DepthGadget,    TRUE,
  153.         WA_Activate,    TRUE,
  154.         WA_SmartRefresh,    TRUE,
  155.         WA_AutoAdjust,    TRUE
  156.     )) {
  157.  
  158.         GT_RefreshWindow(w, NULL);
  159.  
  160.         for (i=0; i<AB_LINES; i++) if (abTexts[i]) {
  161.         it.IText = abTexts[i];
  162.         it.LeftEdge = (maxlen-IntuiTextLength(&it))/2;
  163.         PrintIText(w->RPort, &it,
  164.             si->WLeft+si->xTimes, (i+1)*si->font->ta_YSize+si->WTop);
  165.         }
  166.  
  167.         while (!done) {
  168.         Wait(1L << w->UserPort->mp_SigBit);
  169.         while ((imsg=GT_GetIMsg(w->UserPort)) && (!done)) {
  170.             Class = imsg->Class;
  171.             g = (struct Gadget *) imsg->IAddress;
  172.             GT_ReplyIMsg(imsg);
  173.             switch (Class) {
  174.  
  175.             case IDCMP_GADGETUP:
  176.             if (g->GadgetID==DA_GO_ON) done=TRUE;
  177.             break;
  178.  
  179.             case IDCMP_CLOSEWINDOW:
  180.             done=TRUE;
  181.             break;
  182.  
  183.             case IDCMP_REFRESHWINDOW:
  184.             GT_BeginRefresh(w);
  185.             GT_EndRefresh(w, TRUE);
  186.             break;
  187.  
  188.             default:
  189.             break;
  190.  
  191.             }
  192.         }
  193.         }
  194.  
  195.         CloseWindow(w);
  196.     }
  197.  
  198.     }
  199.  
  200.     FreeGadgets(glist);
  201.  
  202.     DBUG_VOID_RETURN;
  203. }
  204.